#!/bin/bash

DIRECTORY="$(dirname "$(dirname "$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )")")"

function error {
  echo -e "\\e[91m$1\\e[39m"
  exit 1
}

rm -f ~/tor.tar.xz
wget -O ~/tor.tar.xz https://sourceforge.net/projects/tor-browser-ports/files/10.5.8/tor-browser-linux-arm64-10.5.8_en-US.tar.xz/download || error "Failed to download!"

tar -xf ~/tor.tar.xz || error "Failed to extract!"
rm -f ~/tor.tar.xz

echo "[Desktop Entry]
Type=Application
Name=Tor Browser
GenericName=Web Browser
Comment=Tor Browser is +1 for privacy and −1 for mass surveillance
Categories=Network;WebBrowser;Security;
Exec=$HOME/tor-browser_en-US/Browser/start-tor-browser
X-TorBrowser-ExecShell=./Browser/start-tor-browser --detach
Icon=$(dirname "$0")/icon-64.png
StartupWMClass=Tor Browser" > ~/.local/share/applications/tor.desktop
